﻿@model IEnumerable<GameSchool.Models.Common.Notification>

@{
    ViewBag.Title = "Tilkynningar";
    Layout = "~/Views/Shared/_Layout.cshtml";

    GameSchool.Models.Person loggedOnPerson;
    loggedOnPerson = GameSchool.Extra.UserInfo.GetLoggedOnPerson();
    bool isAdmin = (loggedOnPerson != null && loggedOnPerson.IsAdmin);
    bool isTeacher = (loggedOnPerson != null && loggedOnPerson.IsTeacher);
    bool isStudent = (loggedOnPerson != null && loggedOnPerson.IsStudent);
   }

<h2>Tilkynningar</h2>

@if (isTeacher || isAdmin)
{
    <p>
        @Html.ActionLink("Skrá nýja tilkynningu", "CreateNotification")
    </p>
}
<table>
    <tr>
        <th>
            Námskeið
        </th>
        <th>
            Titill
        </th>
        <th>
            Skilaboð
        </th>
        <th>
            Dagsetning
        </th>
        @if (isTeacher || isAdmin)
        {
        <th></th>
        }
    </tr>

@foreach (var item in Model.OrderByDescending(x => x.EntryDate)) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Course.CourseName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Title)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.NotificationMessage)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.EntryDate)
        </td>
        @if (isTeacher || isAdmin)
        {
            <td>
                @Html.ActionLink("Breyta", "EditNotification", new { id = item.NotificationId }) 
                @Html.ActionLink("Nánar", "DetailsNotification", new { id = item.NotificationId }) 
          
            </td>
        }
    </tr>
}

</table>
